Quiz Panel functionality
QuizPanel
Prefab that works as a quiz container. It appears as an empty panel that can be easily customized via the inspector. It's possible to manage how the title, question and answers disposition appear when activated.

By modifying some parameters in the "Quiz Placeholder" script component it's possible to obtain different quizzes with different functionality depending on the necessity.
Follow the tips written in the inspector to customize the prefab in the right way!
Events and result
The Quiz Placeholder has five events, which a Visual Scripting graph, the Inspector or a script can use: On Finish, On Go To Results, On Edit, On Reset and On Continue. In the WebGL player a user who answers and goes on gets this sequence:
- The user clicks Confirm: On Finish is raised. On Finish is not raised while fewer than Min Selectable Answers are selected. Nothing changes on the panel yet.
- Something must then ask the panel to show the result: the Go To Results node in a graph, or
VSNode_GoToResults(showEditButton, showResetButton, showContinueButton)from a script. The panel marks every answer right or wrong, shows the Feedback texts of the selected answers, and replaces Confirm with the buttons you asked for. - The user clicks Continue (shown when
showContinueButtonis true): On Continue is raised.
A panel without a graph or a script that calls Go To Results stays as it is after Confirm: no result, no feedback, no Continue.
To tell a right answer from a wrong one from a script or a graph, note that for every answer IsCorrectSelection is IsSelected == correctAnswer: an answer you should not select counts as right while it is left unselected. A user who got everything right has selected every correct answer and no other, and then the number of right answers equals the number of answers:
using UnityEngine;
using Virtuademy.Environments.ScriptingApi.Placeholders;
public class QuizWatcher : MonoBehaviour
{
[SerializeField] private QuizPlaceholder quiz;
private void OnEnable()
{
quiz.onFinish.AddListener(OnFinish);
quiz.onContinue.AddListener(OnContinue);
}
private void OnDisable()
{
quiz.onFinish.RemoveListener(OnFinish);
quiz.onContinue.RemoveListener(OnContinue);
}
private void OnFinish()
{
bool allRight = quiz.QuizInstanceCorrectAnswersCount == quiz.QuizInstanceAnswersCount;
Debug.Log("Score " + quiz.QuizInstanceScore + " of " + quiz.QuizInstanceAllGoodScore + ", all right: " + allRight);
// Show right/wrong and the feedback, with a Continue button (no Edit, no Reset).
quiz.VSNode_GoToResults(false, false, true);
}
private void OnContinue()
{
// Go on to the next step.
}
}
QuizInstanceAnswers lists the answers shown, each with IsSelected, IsCorrectSelection and CurrentScore. In a graph, the Expose Quiz Instance node gives the same numbers: see Quiz nodes.
The QuizPanel MultiAnswer and QuizPanel SingleAnswer exist but are not configured with the expected specialized settings. They behave the same way of QuizPanel.